import React, { Component } from 'react';

class App extends Component {

  constructor(props){
    super(props)

    // 修改 this 指向
    this.add = this.add.bind(this)
  }

  state = {
    count: 100
  }

  add = function(){
    console.log('被点击了', this);
  }

  render() {
    return (
      <div>

        <h1>{this.state.count}</h1>
        <button onClick={this.add}>点击增加</button>
      </div>
    );
  }
}

export default App;
